<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/WEB-INF/jsp/sys/include.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<base href="<%=basePath%>"/>
<title>用户管理</title>

	
	<link href="css/global.css" type="text/css" rel="stylesheet"/>

	
	<link rel="stylesheet" type="text/css" href="css/easydialog.css" />
	<script src="js/easydialog.min.js" type="text/javascript"></script>
	
	<script src="js/jquery-1.5.1.js" type="text/javascript"></script>
	<script src="js/jquery.form.js" type="text/javascript"></script>
	<script src="js/jquery.validate.js" type="text/javascript"></script>
	<script src="js/jquery.validate.ms.js" type="text/javascript"></script>
	
	
<style type="text/css">
<!--
body{
	background-color:#ffffff;
	margin:0px; padding:0px;
}
label.error{
	font-weight: bold;
	color: red;
}
-->
</style>
</head>
	<body>
	<div id="main">

	<div id="part1" class="part">
		<p class="title"><a href="#">更新用户</a></p>
		<div class="doc" id="doc2">
				<form id="addDataId" >
				<table>
				<tbody>
				<ta:formToken/>
				<input id="id" name="id" type="hidden" size="35" value="${data.id }" />
				<tr><td>登录ID:</td><td><input id="loginID_id" name="loginID" type="text" class="txt" value="${data.loginID }" /></td></tr>
				<tr><td>密码:</td><td><input id="password_id" name="password" type="password" class="txt" value="${data.password }" /></td></tr>
				<tr><td>重复密码:</td><td><input id="confirm_password_id" name="confirm_password" type="password" class="txt" value="${data.password }"/></td></tr>
				<tr><td>姓名:</td><td><input id="name_id" name="name" type="text" class="txt" value="${data.name }"/></td></tr>
				<tr><td>性别:</td><td><input id="gender_id" name="gender" type="text" class="txt"  value="${data.gender }"/></td></tr>
				<tr><td>电邮:</td><td><input id="email_id" name="email" type="text" class="txt"  value="${data.email }"/></td></tr>
				<tr><td>电话:</td><td><input id="phone_id" name="phone" type="text" class="txt" value="${data.phone }"/></td></tr>
				<tr><td>移动电话:</td><td><input id="mobile_id" name="mobile" type="text" class="txt" value="${data.mobile }"/></td></tr>
				<tr><td>单位:</td><td><input id="orgID_id" name="orgID" type="text" class="txt"  value="${data.orgID }"/></td></tr>
				<tr><td>是否管理员:</td><td><input id="isAdmin_id" name="isAdmin" type="checkbox" <c:if test="${data.isAdmin}">checked='checked'</c:if> size="35" value="1"/></td></tr>
				<tr><td>
				<input value="提交" type="button" id="submitId" class="btn"/>
				<input value="重置" type="button" id="resetId" class="btn"/>
				</td><td>
				</td></tr>
				</tbody>
				</table>
				</form>
		</div>
	</div>
	</body>
	<script type="text/javascript">
	
$(document).ready(function(){
	var validator = $("#addDataId").validate({
			focusInvalid: true,//表单提交时,焦点会指向第一个没有通过验证的域
		success: function(label) {
			label.html("<font color='green'>正确！</font>");
		},
		rules: {
			loginID:{
				required:true,
				rangelength:[5,10],
				remote: {
			        type:"POST",
			        url:"sysQueryUserByUsername.do", 
			        dataType: "text",
			        data:{
			        	loginID: function() {
				            return $("#loginID_id").val();
				        },
				        origindata:"${data.loginID }"
			        }
				}
			},
			name:{
				required:true,
				rangelength:[5,10]
			},
			password:{
				required:true,
				rangelength:[5,10]
			},
			confirm_password:{
				required: true,
				equalTo: "#password_id"
				
			}
		},
		messages:{
			loginID:{
				required:"请输入用户名",
				rangelength:"长度范围在5-10之间",
				remote: "用户名已经存在"
			},
			name:{
				required:"请输入姓名",
				rangelength:"长度范围在5-10之间"
			},
			password: {
		    	required: "请输入密码",
				rangelength:"长度范围在5-10之间"
		   	},
		   	confirm_password:{
				required: "请输入确认密码",
    			equalTo: "两次输入密码不一致"
				
		   	}
			
		}
	});
	
	$('#submitId').click(function(){
			if(true == validator.form()){
				var options = {
					url:'sysUserUpdateAction.do',
					type:'POST',
					success:function(data) {
		         		if("true" == data){
		         			easyDialog.open({
								container : {
									header : '信息提示',
									content : '数据提交成功！',
									yesFn : function(){
		         								
		         								window.location="sysUserQuery.do";
		         								window.reload();
		         								//return true;
		         							}
								}
							});
									         			
		         		}else if("repeatSubmit" == data){
		         			easyDialog.open({
								container : {
									header : '信息提示',
									content : '数据已提交，请不要重复操作！',
									yesFn : function(){return true;}
								}
							});
		         		}else{
		         			
		         			easyDialog.open({
								container : {
									header : '信息提示',
									content : '数据提交失败！',
									yesFn : function(){return true;}
								}
							});
		         		}
		     		}
				};
				$('#addDataId').ajaxSubmit(options);
				return false;
			}else{
				return false;
			}
	    });

	$("#resetId").click(function() {
        validator.resetForm();
    });
	
	
});


</script>
</html>

